<template>
  <div>
    <button @click="search">擦寻</button>
    <div class="main" ref="main">
      <!-- <img :src="require('D:/桌面/热成像导出图像/20220705-097813-轴承温度-1.jpg')" alt=""> -->
      <!-- <div v-for="(item,index) in fileList" :key="index"> -->
        <!-- {{require("" + item.filePath + "")}} -->
        <!-- <img v-if="!!item.filePath" :src="require(item.filePath)" alt=""> -->
      <!-- </div> -->
    </div>
  </div>
</template>

<script>
export default {
  props: {
  },
  data() {
    return {
      fileNameList:[],
      fileList: [],
      useList:[]
    }
  },
  created(){
    // this.getFiles("D:/桌面/热成像导出图像")
    // this.getFileList()
    // 传入图片地址
    this.getPath("D:/桌面/热成像导出图像")
  },
  mounted() {
  },
  methods: {
    // 调用文件信息
    async getFiles(path) {
      this.$http.get("/gee/getLocalFiles?" + `path=${path}`)
    },
    async getFileList() {
      const data = await this.$http.get("/gee/getFilePath")
      this.fileList = data.data.fileList
      console.log(data)
    },
    async getPath(path) {
      const filePath = await this.$http.get("/gee/getPath?path=" + path)
      this.fileList = filePath.data.filePathList
      this.fileNameList = filePath.data.fileList
      // this.fileList.forEach(item => {
      //   // filePath
      //   item.filePath = 
      //   this.useList
      // })
      console.log(filePath.data)
    },
    search1(){
      console.log(123)
      console.log(this.fileList)
    },
    search(){
      
      this.fileNameList.forEach(item => {
        console.log(item.filePath)
        if(item.suf === "jpg"){
          let img = document.createElement("img")
          img.src = require("D:/桌面/热成像导出图像/" + item.item)
          this.$refs.main.appendChild(img)
          console.log(item.suf)
        }
        if(item.suf === "mp4") {
          let video = document.createElement("video")
          // video.src = require("@/assets/files/" + item.item)
          video.width = "192"
          video.height = "256"
          video.controls = "controls"
          let source = document.createElement("source")
          source.src = require("D:/桌面/热成像导出图像/" + item.item)
          source.type = "video/mp4"
          video.appendChild(source)
          this.$refs.main.appendChild(video)
          console.log(item.suf)
        }
      })
    }
  }
}
</script>

<style scoped>
</style>
